package com.st.controller;

import com.st.entity.*;
import com.st.service.IViewTicketService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/ticket")
public class ViewTicketController {
    @Autowired
    private IViewTicketService iViewTicketService;
    //搜索+分页
    @RequestMapping("/ticketSearch")
    public PageResult<ViewTicket> search(@RequestBody PageDTO<ViewTicket> pageDTO){
        PageResult<ViewTicket> search = iViewTicketService.search(pageDTO);
        return search;
    }
    //查找所有景区
    @RequestMapping("/scenicSearch")
    public Result scenicSearch(){
        return iViewTicketService.scenicSearch();
    }
    //添加门票或编辑
    @RequestMapping("/addTicket")
    public Result addTicket(@RequestBody Ticket ticket){
        return  iViewTicketService.addTicket(ticket);
    }
    @RequestMapping("/edit")
    public Result edit(@RequestBody Ticket ticket){
        return iViewTicketService.edit(ticket);
    }
    //删除
    @RequestMapping("/del")
    public Result del(@RequestBody Ticket ticket){
        return iViewTicketService.del(ticket);
    }
    //批量删除
    @RequestMapping("/delAll")
    public Result delAll(@RequestBody List<Integer> ids){
        return iViewTicketService.delAll(ids);
    }
}
